<template>
  <el-container>
    <el-aside>
      <el-menu
        :default-active="activeMenu"
        @select="selectMenu"
        background-color="#545c64"
        text-color="#fff"
        active-text-color="#ffd04b">
        <el-menu-item index="role">
          <el-icon>
            <Avatar/>
          </el-icon>
          <template #title>角色管理</template>
        </el-menu-item>
        <el-menu-item index="perm">
          <el-icon>
            <Key/>
          </el-icon>
          <template #title>权限管理</template>
        </el-menu-item>
      </el-menu>
    </el-aside>
    <el-main>
      <router-view v-slot="{ Component, route }">
        <transition :name="route.meta.transition">
          <keep-alive v-if="route.meta.keepAlive">
            <component :is="Component" />
          </keep-alive>
          <component v-else :is="Component" />
        </transition>
      </router-view>
    </el-main>
  </el-container>
</template>

<script>
export default {
  name: "Index",
  data() {
    return {
      activeMenu: "role"
    };
  },
  mounted() {
    this.activeMenu = this.$route.name || "";
  },
  methods: {
    selectMenu(name) {
      this.$router.push({name: name})
    }
  }
};
</script>

<style lang="scss" scoped>
.el-container {
  flex: 1;
  display: flex;
  flex-direction: row;

  .el-aside {
    width: auto !important;
    background-color: #545c64;
  }

  .el-menu {
    border-right: 0;
  }

  .el-menu-item {
    padding-right: 30px;
  }

  .el-main {
    padding: 0;
    display: flex;
    flex-direction: column;
    text-align: left;
    overflow: hidden;
  }
}
</style>